# Determine DirectInput API include and library paths. 
# Once done, the following is defined
#  DIRECTINPUT_FOUND 
#  DirectInput_INCLUDE_DIR 
#  DirectInput_LIB (intermediate result)
#  DirectInput_GUID_LIB	(intermediate result)
#  DirectInput_LIBRARIES
IF( CMAKE_SYSTEM_NAME MATCHES Windows )

	# The main/root path where DirectInput should be found 
	SET( DirectX_SDK_ROOT_PATH "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)" CACHE STRING "The root path of the DirectX SDK where DirectInput can be found" )
	
	# Determine the header path
	FIND_PATH( DirectInput_INCLUDE_DIR NAMES dinput.h PATHS "${DirectX_SDK_ROOT_PATH}/Include" NO_DEFAULT_PATH  )
		
	# Determine the library paths depending on the architecture (x86 or x64)
	IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
		FIND_LIBRARY( DirectInput_LIB NAMES dinput8 PATHS "${DirectX_SDK_ROOT_PATH}/Lib/x64" NO_DEFAULT_PATH )
		FIND_LIBRARY( DirectInput_GUID_LIB NAMES dxguid PATHS "${DirectX_SDK_ROOT_PATH}/Lib/x64" NO_DEFAULT_PATH )
	ELSE()
		FIND_LIBRARY( DirectInput_LIB NAMES dinput8 PATHS "${DirectX_SDK_ROOT_PATH}/Lib/x86" "${DirectX_SDK_ROOT_PATH}/Lib" NO_DEFAULT_PATH )
		FIND_LIBRARY( DirectInput_GUID_LIB NAMES dxguid PATHS "${DirectX_SDK_ROOT_PATH}/Lib/x86" "${DirectX_SDK_ROOT_PATH}/Lib" NO_DEFAULT_PATH )
	ENDIF()
		
	INCLUDE( FindPackageHandleStandardArgs )
	FIND_PACKAGE_HANDLE_STANDARD_ARGS( DirectInput DEFAULT_MSG DirectInput_LIB DirectInput_GUID_LIB DirectInput_INCLUDE_DIR )
		
	SET( DirectInput_LIBRARIES ${DirectInput_LIB} ${DirectInput_GUID_LIB} )
	
ENDIF()